pub mod services;
pub mod commands;

use services::{video_service::VideoService, file_service::FileService};
use commands::video_commands::*;

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    // 初始化视频服务
    let video_service = VideoService::new()
        .expect("Failed to initialize video service");
    
    // 初始化文件服务
    let file_service = FileService::new();

    tauri::Builder::default()
        .plugin(tauri_plugin_opener::init())
        .plugin(tauri_plugin_dialog::init())
        .plugin(tauri_plugin_fs::init())
        .manage(video_service)
        .manage(file_service)
        .invoke_handler(tauri::generate_handler![
            greet,
            convert_video,
            extract_audio,
            get_video_info,
            batch_process_videos,
            get_supported_video_formats,
            get_supported_audio_formats,
            get_active_tasks,
            cancel_task,
            select_video_file,
            select_video_files,
            select_output_directory,
            create_output_path,
            validate_video_file,
            get_ffmpeg_info
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
